<template>
	<view class="cu-form-group">
		<view class="title">{{title}}</view>
		<picker mode="date" :value="date"  @change="DateChange">
			<view class="picker">
				{{(date==null||date=="")?'请选择日期':date}}
			</view>
		</picker>
	</view>
</template>

<script>
	import store from "@/store";
	import {
		mapGetters
	} from "vuex";
	
	export default {
		name: "datePicker",
		computed: {
			...mapGetters(["userInfo"]),
		},
		props: {
			title: {
				type: String,
				default: "日期选择"
			},
			value: {
				type: [Number, String],
				default: ''
			},
		},
		watch: {
		
			"value": {
				immediate: true, //该回调将会在侦听开始之后被立即调用
				handler: function(n, o) {
					if (n) {
						this.date =n;
					}
				}
			}
		},
		data() {
			var year=new Date().getFullYear()+1;
			let endDate=`${year}-01-01`
			return {
				start:"1930-01-01",
				end: endDate,
				date:'',
			};
		},
		methods:{
			DateChange(e){
				this.date=e.detail.value;
				this.$emit('input', this.date);
			}
		}
	}
</script>

<style>

</style>